package cn.zkrt.iotms.module.iot.controller;

import cn.zkrt.iotms.module.iot.entity.DeviceWtblAttributeRelationB;
import cn.zkrt.iotms.module.iot.service.DeviceWtblAttributeRelationBService;
import cn.zkrt.iotms.module.iot.vo.DeviceWtblAttributeRelationBVO;
import io.swagger.annotations.Api;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import cn.zkrt.iotms.comm.R;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;
import javax.annotation.Resource;

/**
 * 设备物通博联属性与设备属性关联表(DeviceWtblAttributeRelationB)表控制层
 *
 * @author xulinyu
 * @since 2024-10-09 16:08:13
 */
@RestController
@RequestMapping("deviceWtblAttributeRelationB")
@Api(tags = "5物联网属性配置")
public class DeviceWtblAttributeRelationBController {
    /**
     * 服务对象
     */
    @Resource
    private DeviceWtblAttributeRelationBService deviceWtblAttributeRelationBService;

    /**
     * 分页查询
     *
     * @param varName 筛选条件
     * @param page      分页对象
     * @return 查询结果
     */
    @GetMapping
    public R<Page<DeviceWtblAttributeRelationBVO>> queryByPage(Page<DeviceWtblAttributeRelationBVO> page, String deviceName, String typeAttributeName, String varName) {
        return R.data(this.deviceWtblAttributeRelationBService.queryByPage(page, deviceName,typeAttributeName,varName));
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    public R<DeviceWtblAttributeRelationBVO> queryById(@PathVariable("id") String id) {
        return R.data(this.deviceWtblAttributeRelationBService.queryById(id));
    }

    /**
     * 新增数据
     *
     * @param deviceWtblAttributeRelationB 实体
     * @return 新增结果
     */
    @PostMapping
    public R<Boolean> add(@Validated @RequestBody DeviceWtblAttributeRelationB deviceWtblAttributeRelationB) {
        return R.data(this.deviceWtblAttributeRelationBService.add(deviceWtblAttributeRelationB));
    }

    /**
     * 编辑数据
     *
     * @param deviceWtblAttributeRelationB 实体
     * @return 编辑结果
     */
    @PutMapping
    public R<Boolean> edit(@Validated @RequestBody DeviceWtblAttributeRelationB deviceWtblAttributeRelationB) {
        return R.data(this.deviceWtblAttributeRelationBService.edit(deviceWtblAttributeRelationB));
    }

    /**
     * 删除数据
     *
     * @param idList 主键集合
     * @return 删除是否成功
     */
    @DeleteMapping
    public R<Boolean> deleteByIds(@RequestParam("idList") List<Long> idList) {
        return R.data(this.deviceWtblAttributeRelationBService.removeByIds(idList));
    }

}

